﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="设备编码表管理.aspx.cs" Inherits="syc.Jidong.设备编码表管理" %>
<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript" language="javascript" src="/common.js"></script>
<form id="form1" runat="server">
<asp:Label ID="SelectedID" runat="server" Text="" Visible="false"></asp:Label>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>"
SelectCommand="select
编码,资产
,rtrim(编码)+'|'+cast(资产 as varchar) as CODE
,case when 资产=0 and len(编码)=6 or 资产=1 and len(编码)=8 then
    cast(0 as bit)
else
    cast(1 as bit)
end as 扩展
,case when 资产=0 then
 case when len(编码)=2 then '一级单位码'
 when len(编码)=4 then '二级单位码'
 when len(编码)=6 then '三级单位码'
 else
  '无效编码'
 end
else
 case when len(编码)=2 then '资产编码大类'
 when len(编码)=4 then '资产编码中类'
 when len(编码)=6 then '资产编码小类'
 when len(编码)=8 then '资产编码小小类'
 else
  '无效编码'
 end
end
as 级别
,名称
from 设备编码 order by 资产 asc,编码 asc"
UpdateCommand="update 设备编码 set 名称=@名称 where 编码=@编码 and 资产=@资产"
DeleteCommand="delete 设备编码 where 编码=@编码 and 资产=@资产"
onselected="SqlDataSource1_Selected" ></asp:SqlDataSource>
<div id="wintop" class="wintop">设备编码表管理</div>
<asp:Panel ID="Panel1" runat="server" CssClass="panel">
<asp:Button ID="Button_New" runat="server" Text="新增一级单位" CssClass="button2" 
        UseSubmitBehavior="false" onclick="Button_New_Click"  />
<asp:Button ID="Button_New2" runat="server" Text="新增资产大类" CssClass="button2" 
        UseSubmitBehavior="false" onclick="Button_New2_Click"  />
</asp:Panel>

<asp:Panel ID="Panel2" runat="server" CssClass="panel" Visible="false">
<span style="display:inline-block;width:120px;">上级编码:<asp:Label ID="Label_ShangJi" runat="server" Text=""></asp:Label></span>
<span style="display:inline-block;width:160px;">编码<span class=required>*</span>:<asp:TextBox ID="BianMa" runat="server" CssClass="textbox" Width="40px"></asp:TextBox>(1-99)</span>
名称<span class=required>*</span>:<asp:TextBox ID="MingCheng" runat="server" CssClass="textbox" Width="200px"></asp:TextBox>
<asp:CheckBox ID="ZhiChan" runat="server" Text="资产类" Enabled="false" />
<asp:Button ID="Button_Save" runat="server" Text="保 存" CssClass="mbutton" 
        UseSubmitBehavior="false" onclick="Button_Save_Click" />
<asp:Button ID="Button_Cancel" runat="server" Text="取 消" CssClass="mbutton" 
        UseSubmitBehavior="false" onclick="Button_Cancel_Click" />
</asp:Panel>

<asp:Panel ID="Panel_Msg" runat="server" CssClass="panel2">
    <asp:Label ID="Message" runat="server" Text="·准备就绪" CssClass="prompt"></asp:Label>
</asp:Panel>

<div class="gridframe">
    <div class="gridview">
    
        <table border="1" width="100%" cellspacing="0" cellpadding="0" bordercolor="#e5cfab">
            <tr>
	            <td class="grid-title">设备编码规则表</td>
	        </tr>
	        <tr>
	            <td class="grid-back">
                    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                        AutoGenerateColumns="False" CssClass="grid" DataKeyNames="编码,资产" 
                        DataSourceID="SqlDataSource1"
                        PageSize="15"
                        GridLines="None" ondatabound="GridView1_DataBound" 
                        onpageindexchanged="GridView1_PageIndexChanged" AllowSorting="True" 
                        UseAccessibleHeader="False" 
                        onselectedindexchanged="GridView1_SelectedIndexChanged">
                        <PagerSettings Visible="False" />
                        <RowStyle CssClass="grid-row-normal" />
                        <Columns>
                        
                            <asp:TemplateField HeaderText="">
                                <ItemTemplate>
                                    <asp:Button ID="Button1" runat="server" CommandName="Select" Text="选择" CssClass="hide"/>
                                    <img src="/Icons/online.gif" style="margin-top:2px;" alt="" />
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="20px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="编码">
                                <ItemTemplate>
                                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("编码") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Left" Width="100px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="级别">
                                <ItemTemplate>
                                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("级别") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Left" Width="100px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="名称">
                                <ItemTemplate>
                                    <asp:Label ID="Label4" runat="server" Text='<%# Bind("名称") %>'></asp:Label>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("名称") %>' Width="240"></asp:TextBox>
                                </EditItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Left" Width="260px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="操作" >
                                <ItemTemplate>
                                    <asp:Button ID="Button_XG" runat="server" CommandName="Edit" Text="修 改" CssClass="smallbutton" UseSubmitBehavior="false" />
                                    <asp:Button ID="Button_KZ" runat="server" Text="扩 展" CssClass="smallbutton" Visible='<%# Bind("扩展") %>'
                                        UseSubmitBehavior="false" CommandName='<%# Bind("CODE") %>' 
                                        onclick="Button_KZ_Click"/>
                                    <asp:Button ID="Button_SC" runat="server" CommandName="Delete" Text="删 除" CssClass="smallbutton" UseSubmitBehavior="false" OnClientClick="if(!confirm(notice))return(false);" />
                               </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:Button ID="Button_GX" runat="server" CommandName="Update" Text="更 新" CssClass="smallbutton" UseSubmitBehavior="true"/>
                                    <asp:Button ID="Button_QX" runat="server" CommandName="Cancel" Text="取 消" CssClass="smallbutton" UseSubmitBehavior="false"/>
                                </EditItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="left" Width="156px" />
                            </asp:TemplateField>
                            

                        </Columns>
                        <SelectedRowStyle CssClass="grid-row-selected" />
                      </asp:GridView>
	            </td>
            </tr>
            <tr>
	            <td>   
	                <table width="100%">
	                    <tr>
	                        <td class="pagebar">
                                <asp:Button ID="Button_Pager_First" UseSubmitBehavior="false" runat="server" Text="" ToolTip="首页" 
                                    CssClass="pageturn-first-b" onclick="Pager_Click" CommandName="--" />
                                <asp:Button ID="Button_Pager_Prev" UseSubmitBehavior="false" runat="server" Text="" ToolTip="上一页" 
                                    CssClass="pageturn-prev-b" onclick="Pager_Click" CommandName="-" />
                                <input type="button" class="page-split" UseSubmitBehavior="false" disabled />第<asp:TextBox 
                                    ID="TextBox_Pager" AutoPostBack="True" runat="server" CssClass="pageturn" 
                                    ontextchanged="Pager_Click"></asp:TextBox>页<input type="button" class="page-split" disabled /><asp:Label ID="Label_Pages" UseSubmitBehavior="false" runat="server"></asp:Label><input type="button" class="page-split" disabled />
                                
                                <asp:Button ID="Button_Pager_Next" UseSubmitBehavior="false" runat="server" Text="" ToolTip="下一页" 
                                    CssClass="pageturn-next-b" onclick="Pager_Click" CommandName="+" />
                                <asp:Button ID="Button_Pager_Last" UseSubmitBehavior="false" runat="server" Text="" ToolTip="末页" 
                                    CssClass="pageturn-last-b" onclick="Pager_Click" CommandName="++" /><asp:Label ID="Label9" runat="server"></asp:Label><input type="button" class="page-split" disabled />
                            </td>
                            <td class="pagebar" align="right">
                                <asp:Label ID="Label_Total" runat="server"></asp:Label>
                            </td>
                        </tr>
                   </table>

	            </td>
            </tr>
        </table>
        

    </div>
</div>

</form>
<script>
    var notice = '确认要删除该条记录吗？';
    var textboxs = document.getElementsByTagName("input");
    var i;
    for (i = 0; i < textboxs.length; i++) {
        if (textboxs[i].className == "textbox") {
            textboxs[i].onchange = function(e) { this.className = "textbox-changed"; };
            textboxs[i].onfocus = function(e) { this.select(); };
        }
        else if (textboxs[i].className == "pageturn" || textboxs[i].className == "intxt1" || textboxs[i].className == "intxt2") {
            textboxs[i].onfocus = function(e) { this.select(); };
        }
    }
    var rows = document.getElementsByTagName("tr");
    for (i = 0; i < rows.length; i++) {

        if (rows[i].className == "grid-row-normal") {
            rows[i].onmouseover = function() { this.className = "grid-row-bright"; };
            rows[i].onmouseout = function() { this.className = "grid-row-normal"; };
            //rows[i].onclick = selectRow;
        }
    }
    var tds = document.getElementsByTagName("td");
    for (i = 0; i < tds.length; i++) {
        if (tds[i].className == "detailheader") {
            tds[i].innerHTML = tds[i].innerHTML.replace("*", "<span class=required>*</span>");
        }
    }
    function checkenter(e) {
        if (!e) e = window.event;
        if (e.keyCode == 13) {
            e.keyCode = 9;
        }
    }
    var BianMa = document.getElementById("BianMa");
    if (BianMa) BianMa.onkeydown = checkenter;
    var MingCheng = document.getElementById("MingCheng");
    if (MingCheng) BianMa.onkeydown = checkenter;

    function insert(o) {
        var row = o.parentNode.parentNode.insertRow(o.rowIndex+1);
        var col = row.insertCell(0);
        col.colSpan = 5;
        row.className = "grid-row-normal"
        col.className = "grid";
        col.innerHTML = "asd";
    }
</script>
</body>
</html>
